<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>详情</title>
    <link rel="stylesheet" type="text/css" href="/static/hplus/css/bootstrap.min.css">
    <link rel="stylesheet" type="text/css" href="/static/hplus/css/style.css">
    <link rel="stylesheet" type="text/css" href="/static/layer/skin/layer.css">
    <style type="text/css">
        .form-horizontal .control-label {padding-top: 0;}
    </style>
</head>
<body class="gray-bg">
<div class="wrapper wrapper-content">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox-title">
                <div class="ibox-tools"><a href="javascript:;" class="btn btn-primary blue-skin go_back">返回</a></div>
                <h3>用户详情</h3>
            </div>
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <div class="ibox-tools"><a class="btn btn-primary btn-xs" href="javascript:;" data-action="basic" data-id="{$user.id}">编辑基本资料</a>
                    </div>
                    <h5>基本资料</h5>
                </div>
                <div class="ibox-content">
                    <form class="form-horizontal">
                        <div class="col-sm-12">
                            <div class="form-group">
                                <label class="col-sm-1 control-label">用户头像</label>
                                <div class="col-sm-8">
                                    <a href="{$user.avatar}" target="_blank" title="点击查看大图"><img src="{$user.avatar}" style="max-width: 60px;max-height: 60px;"></a>
                                </div>
                            </div>
                        </div>
                        <div class="hr-line-dashed" style="clear: both"></div>
                        <div class="col-sm-4">
                            <div class="form-group">
                                <label class="col-sm-4 control-label">登录账号</label>
                                <div class="col-sm-8">{$user.username}</div>
                            </div>
                            <div class="hr-line-dashed"></div>
                            <div class="form-group">
                                <label class="col-sm-4 control-label">用户类型</label>
                                <div class="col-sm-8">
                                    {foreach $category as $k=>$r}
                                    {if($user.category==$k)}{$r}{/if}
                                    {/foreach}
                                </div>
                            </div>
                            <div class="hr-line-dashed"></div>
                            <div class="form-group">
                                <label class="col-sm-4 control-label">用户年龄</label>
                                <div class="col-sm-8">{$user.age}</div>
                            </div>
                            <div class="hr-line-dashed"></div>
                            <div class="form-group">
                                <label class="col-sm-4 control-label">证件号</label>
                                <div class="col-sm-8">{$user.idcard??''}</div>
                            </div>
                        </div>
                        <div class="col-sm-4">
                            <div class="form-group">
                                <label class="col-sm-4 control-label">手机号</label>
                                <div class="col-sm-8">{$user.mobile}</div>
                            </div>
                            <div class="hr-line-dashed"></div>
                            <div class="form-group">
                                <label class="col-sm-4 control-label">真实姓名</label>
                                <div class="col-sm-8">{$user.name}</div>
                            </div>
                            <div class="hr-line-dashed"></div>
                            <div class="form-group">
                                <label class="col-sm-4 control-label">状态</label>
                                <div class="col-sm-8">
                                    {foreach($status as $k=>$s)}
                                    {if($user.status==$k)}{$s}{/if}
                                    {/foreach}
                                </div>
                            </div>
                            <div class="hr-line-dashed"></div>
                            <div class="form-group">
                                <label class="col-sm-4 control-label">登录时间</label>
                                <div class="col-sm-8">{$user.login_time}</div>
                            </div>
                        </div>
                        <div class="col-sm-4">
                            <div class="form-group">
                                <label class="col-sm-4 control-label">昵称</label>
                                <div class="col-sm-8">{$user.nickname}</div>
                            </div>
                            <div class="hr-line-dashed"></div>
                            <div class="form-group">
                                <label class="col-sm-4 control-label">用户性别</label>
                                <div class="col-sm-8">{if($user.gender==1)}男{elseif($user.gender==2)}女{else}保密{/if}</div>
                            </div>
                            <div class="hr-line-dashed"></div>
                            <div class="form-group">
                                <label class="col-sm-4 control-label">登录次数</label>
                                <div class="col-sm-8">{$user.login_count}</div>
                            </div>
                            <div class="hr-line-dashed"></div>
                            <div class="form-group">
                                <label class="col-sm-4 control-label">登录IP</label>
                                <div class="col-sm-8">{$user.login_ip}</div>
                            </div>
                        </div>
                        <div style="clear: both"></div>
                    </form>
                </div>
            </div>
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <div class="ibox-tools"><a class="btn btn-primary btn-xs" href="javascript:;" data-action="extend" data-id="{$user.id}">编辑扩展资料</a>
                    </div>
                    <h5>扩展资料</h5>
                </div>
                <div class="ibox-content">
                    <form class="form-horizontal">
                        <?php $n=1;?>
                        {foreach($arr as $k=>$r)}
                        <div class="col-sm-4">
                            <div class="form-group">
                                <label class="col-sm-4 control-label">{$r}</label>
                                <div class="col-sm-8">{php}if(isset($user_attr[$k])){if(isset($values[$k][$user_attr[$k]])){echo $values[$k][$user_attr[$k]];}else{echo $user_attr[$k];}}{/php}</div>
                            </div>
                        </div>
                        {if($n%3==0)}
                        <div style="clear: both"></div>
                        <div class="hr-line-dashed" style="margin: 0 0 20px 0;"></div>
                        {/if}
                        <?php $n++;?>
                        {/foreach}
                        <div style="clear: both"></div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
</body>
<script type="text/javascript" src="/static/hplus/js/jquery.min.js?v={php}echo time(){/php}"></script>
<script type="text/javascript" src="/static/layer/layer.js?v={php}echo time(){/php}"></script>
<script type="text/javascript">
    $(function () {
        let $open = null;
        $('[data-action]').click(function () {
            let $id = $(this).data('id'), $action = $(this).data('action'), $url = '', $title = ''
            if ($action === 'basic') {
                $title = '编辑用户基本资料';
                $url = '/user/edit?id=' + $id
            } else if ($action === 'extend') {
                $title = '编辑用户扩展资料';
                $url = '/user/editextend?id=' + $id
            } else {
                layer.msg('非法操作');
                return false
            }
            $open = layer.open({
                type: 2,
                title: $title,
                content: $url,
                area: ['600px', '700px'],
                closeBtn: 2,
                btn: ['确定', '取消'],
                yes: function ($index, $layero) {
                    let $body = $layero.find('iframe').contents().find('body');
                    let $param = decodeURIComponent($($body).find('form').serialize());
                    $param = $param.split('&');
                    let $params = {};
                    $($param).each(function ($n, $obj) {
                        $params[$obj.split('=')[0]] = $obj.split('=')[1];
                    });
                    $params['id'] = $id
                    $.ajax({
                        type: 'post', dataType: 'json', cache: false,
                        url: $url,
                        data: $params,
                        beforeSend: function () {
                            layer.load(2, {shade: [0.3, '#fff']})
                        },
                        success: function ($data) {
                            layer.closeAll();
                            if ($data.code === 200) {
                                layer.msg($data.message, {icon: 1, time: 1200}, function () {
                                    window.location.reload();
                                });
                            } else {
                                layer.msg($data.message, {icon: 5});
                            }
                        }
                    })
                }
            })
        })
        $('.go_back').click(function () {
            location.href='/user/lists'
        })
    });
</script>
</html>
